#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void Count_9(int m, int* k)
{
	while (m)
	{
		if (m % 10 == 9)
		{
			(*k)++;
		}
		m /= 10;
	}
}
int main()
{
	int count = 0;
	int edge = 0;
	scanf("%d", &edge);
	for (int i = 1; i <= edge; i++)
	{
		Count_9(i,&count);
	}
	printf("%d", count);
	return 0;
}